<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
 * CodeIgniter Extended HTML Helpers for css and js
 *
 * @package		Application
 * @subpackage	Helpers
 * @category	Helpers
 * @author		Nugroho Nindyo Harimukti
 */


/**
 * Usage: echo css_tag(array('style.css'=>'all'));
 * Result: <link rel='stylesheet' href='http://baseurl/files/css/style.css' media='all'/>
 */
if(!function_exists('css_tag'))
{
	function css_tag($css, $dir = 'css'){
		if(!is_array($css)){
			return '';
		}
		else{
			$links = '';
			foreach($css as $key => $val){
				$media = ($val != '')? "media='$val'": '';
				$links .= "<link rel='stylesheet' href='".base_url()."$dir/$key' $media/>\n";
			}
			return $links;
		}
	}
}

/**
 * Usage: echo js_tag('script.js');
 * Result: <script type='text/javascript' src='http://baseurl/files/js/script.js'></script>
 */
if(!function_exists('js_tag'))
{
	function js_tag($js, $dir = 'js'){
		if(!is_array($js)){
			return "<script type='text/javascript' src='".base_url()."$dir/$js'></script>\n";
		}
		else{
			$scripts = '';
			foreach($js as $j){
				$scripts .= "<script type='text/javascript' src='".base_url()."$dir/$j'></script>\n";
			}
			return $scripts;
		}
	}
}